import { TestGet, TestPost } from '../../api/test'
export default {
  namespaced: true,
  state: {
    Demo: 'demo'
  },
  getters: {
    Demo: (state) => state.Demo
  },
  mutations: {
    setDemo(state, argData) {
      state.Demo = argData
    },
  },
  actions: {
    async 'setDemoA' ({ commit }, param = {}) {
      const _result = await new Promise(resolve => {
        setTimeout(() => resolve('demo1'), 1000)
      })
      commit('setDemo', _result)
      if (_result.code === 200) {
        return _result
      } else {
        return _result
      }
    },
    async TestGet({ commit }, param = {}) {
      const _result = await TestGet(param).catch(err => {
        return Promise.reject(err)
      })
      return _result
    },
    async TestPost({ commit }, param = {}) {
      const _result = await TestPost(param).catch(err => {
        console.log(err)
      })
      return _result
    },
  }
}